package com.practice.Valid和Validated校验;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;


@ApiModel("user实体类")
@Data
public class User {

      @NotNull(message = "id不能为空")
      @Range(message = "年龄范围为 {min} 到 {max} 之间", min = 1, max = 100)
      @ApiModelProperty(name = "id" , value = "用户编号")
      private Integer id;

      @NotNull(message = "id不能为空")
      @AssertTrue(message = "必须是中国人")
      @ApiModelProperty(name = "china" , value = "国籍")
      private boolean china;

      @NotBlank(message = "sex性别不能为空")
      @Size(message = "sex性别描述在{min} 到 {max}个字符之间",min = 1,max = 6)
      @ApiModelProperty(name = "sex" , value = "性别")
      private String sex;

      @NotBlank(message = "username用户名不能为空")
      @Length(message = "名称为 {min} 到 {max} 之间的字符", min = 2,max = 10)
      @ApiModelProperty(name = "username" , value = "用户名")
      private String username;

      @NotEmpty(message = "集合不可为空，且长度必须大于0")
      @ApiModelProperty(name = "address" , value = "地址")
      private List<String> address;
}